﻿using System;
using System.Collections.Generic;
using System.Net.Sockets;
using ApplLogic.ApplClasses;
using ConnectionObjects;

namespace TCPClient.RequestsToServerHandlers
{
    public class RequestsToServerHandlerForWorker : RequestsToServerHandler
    {
        private ApplWorker m_LoggedInWorker;

        public RequestsToServerHandlerForWorker(NetworkStream streamRef, ApplWorker loggedInWorker)
            :base(streamRef)
        {
            m_LoggedInWorker = loggedInWorker;
        }

        public ApplWorker LoggedInWorker
        {
            get { return m_LoggedInWorker; }
            set { m_LoggedInWorker = value; }
        }

        public OutConnectionObject AddSingleShiftRequestToWorker(ApplSingleRequest singleRequestToAdd)
        {
            object[] paramsArr = new object[1];
            paramsArr[0] = singleRequestToAdd;
            InConnectionObject con = new InConnectionObject("AddSingleShiftRequestToWorker", paramsArr, !k_HasReturnValue);
            sendMessage(con);
            return getMessage();
        }

        public OutConnectionObject UpdateSingleShiftRequest(ApplSingleRequest singleRequestToUpdate)
        {
            object[] paramsArr = new object[1];
            paramsArr[0] = singleRequestToUpdate;
            InConnectionObject con = new InConnectionObject("UpdateSingleShiftRequest", paramsArr, !k_HasReturnValue);
            sendMessage(con);
            return getMessage();
        }

        public OutConnectionObject CopyRequestFrom(string workerId, DateTime startTime, DateTime endTime)
        {
            object[] paramsArr = new object[3];
            paramsArr[0] = workerId;
            paramsArr[1] = startTime;
            paramsArr[2] = endTime;
            InConnectionObject con = new InConnectionObject("CopyRequestFrom", paramsArr, !k_HasReturnValue);
            sendMessage(con);
            return getMessage();
        }

        public OutConnectionObject DeleteRequest(ApplSingleRequest requestToDelete)
        {
            object[] paramsArr = new object[1];
            paramsArr[0] = requestToDelete;
            InConnectionObject con = new InConnectionObject("DeleteRequest", paramsArr, !k_HasReturnValue);
            sendMessage(con);
            return getMessage();
        }

        public OutConnectionObject DeleteAllRequestsOfWorkerInDateRange(string workerId, DateTime startTime, DateTime endTime)
        {
            object[] paramsArr = new object[3];
            paramsArr[0] = workerId;
            paramsArr[1] = startTime;
            paramsArr[2] = endTime;
            InConnectionObject con = new InConnectionObject("DeleteAllRequestsOfWorkerInDateRange", paramsArr, !k_HasReturnValue);
            sendMessage(con);
            return getMessage();
        }



        //public OutConnectionObject GetAllWorkersThatGotShift(string shiftId, DateTime startTime, DateTime endTime)
        //{
        //    object[] paramsArr = new object[3];
        //    paramsArr[0] = shiftId;
        //    paramsArr[1] = startTime;
        //    paramsArr[2] = endTime;
        //    InConnectionObject con = new InConnectionObject("GetAllWorkersThatGotShift", paramsArr, k_HasReturnValue);
        //    sendMessage(con);
        //    return getMessage();
        //}


    }
}
